/**
 * Created by chengming on 18/5/27.
 * version 1.0
 */
const BaseJsonAdapter = require('../base/BaseJsonAdapter');
const iconv = require("iconv-lite");
const vm = require('vm');
const request = require('request-promise');
const cheerio = require('cheerio');
const logger = require('../../conf/logger');
const querystring = require("querystring")
const urlencode = require("urlencode")

/**
 */
module.exports = class Uber extends BaseJsonAdapter{

    async reqJson(){
        const body = await this.doRequest();
        let decodeBody = iconv.decode(body, this.encoding).toString();
        let startStr = '<script type="application/javascript">window.__state__ = (';
        let start = decodeBody.indexOf(startStr) + '<script type="application/javascript">'.length;
        let stop = decodeBody.indexOf(');</script><script');
        decodeBody = decodeBody.substring(start,stop).trim().replace(/[\(\)]/g, '');
        let window = {};
        let data =  eval( decodeBody);
        return data;
	}
}
